home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1999 March
/
EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso
/
earcd
/
-archivi
/
-recent2
/
gaplib.lha
/
GAPLib_Beta
/
diagnostic
/
TagListTest.c
< prev
Wrap
C/C++ Source or Header
|
1999-02-07
|
2KB
|
88 lines
#include <stdio.h>
#include <string.h>
#include <GAP.h>
struct Testyphant {
long int foo[4];
};
double dummy_evaluator(struct Testyphant *);
void dummy_crosser(struct Testyphant*,struct Testyphant*);
int main(void)
{
int ret=0;
struct Population *Pop;
struct Testyphant *Testy;
struct TagItem TestTags[] = {
{EVL_Mutator,NULL},
{EVL_Evaluator,0L},
{TAG_IGNORE,4711L},
{TAG_MORE,0L},
{EVL_Stats,FALSE}, /* These two lines should never */
{TAG_DONE,0L} /* be used if all is well. */
};
struct TagItem Test2Tags[] = {
{TAG_IGNORE,17L},
{EVL_Crosser,(IPTR)dummy_crosser},
{TAG_DONE,0L}
};
struct TagItem PopTags[] = {
{POP_Init,ZERO_INIT},
{POP_Cache,TRUE},
{TAG_END,0L}
};
Pop = CreatePopulation(24,sizeof(struct Testyphant),PopTags);
if(Pop!=NULL) {
TestTags[0].ti_Data = (IPTR) dummy_evaluator;
TestTags[2].ti_Data = (IPTR) Test2Tags;
Pop = Evolve(Pop,TestTags);
Testy = PopMember(Pop,1);
if(Testy->foo[0] == 0) {
printf("Possible error in TAG_MORE handling.\n");
ret++;
if(Pop->Stat.Generation == Pop->Generation) {
printf("Possible error in TAG_IGNORE handling.\n");
ret++;
}
}
if(Pop->Stat.Generation != Pop->Generation) {
printf("Possible error in TAG_MORE handling.\n");
ret++;
}
DeletePopulation(Pop);
} else {
printf("Population Creation Failed.\n");
ret = 20;
}
if(ret==0) {
printf("Seems ok.\n");
}
return(0);
}
double dummy_evaluator(struct Testyphant *t)
{
static int i=0;
return((double)i++);
}
void dummy_crosser(struct Testyphant *Polly,struct Testyphant *Tweety)
{
memset(Polly,0xff,sizeof(struct Testyphant));
memset(Tweety,0xff,sizeof(struct Testyphant));
}